<!--
 * @Description: 添加书籍
 * @Author: tyq
 * @Date: 2021-03-07 13:40:25
 * @LastEditors: Wuyi
 * @LastEditTime: 2021-05-30 11:21:34
-->
<template>
<div class="box">
  <div class="addBox">
      <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
        <el-form-item label="书名" prop="bookName">
            <el-input v-model="ruleForm.bookName"></el-input>
        </el-form-item>
        <el-form-item label="作者id" prop="authorId">
            <el-input v-model="ruleForm.authorId"></el-input>
        </el-form-item>
        <el-form-item label="介绍" prop="bookIntro">
            <el-input v-model="ruleForm.bookIntro"></el-input>
        </el-form-item>
        <el-form-item label="书号" prop="book_isbn">
            <el-input v-model="ruleForm.book_isbn"></el-input>
        </el-form-item>
        <el-form-item label="是否推荐" prop="bisRecom">
            <el-input v-model="ruleForm.isRecom"></el-input>
        </el-form-item>
        <el-form-item label="类型id" prop="typeId">
            <el-input v-model="ruleForm.typeId"></el-input>
        </el-form-item>
        <el-form-item class="sure">
          <el-button type="primary" @click="addBook">确认</el-button>
        </el-form-item>
      </el-form>
  </div>
</div>
</template>
<script>
export default {
  name: 'addBook',
  data () {
    return {
      ruleForm: {
        bookName: 'ss',
        authorId: '1',
        bookIntro: '2',
        book_isbn: '3',
        isRecom: '12',
        typeId: '1'
      }
    }
  },
  methods: {
    addBook () {
      this.$http.post('book/addBook', this.ruleForm).then(resp => {
        // console.log('book')
        // console.log(resp)
        if (resp) {
          console.log(resp)
        }
        this.$message.success('添加书籍成功')
        // this.resetFields()
        this.ruleForm.bookName = null
        this.ruleForm.authorId = null
        this.ruleForm.book_isbn = null
        this.ruleForm.bookIntro = null
        this.ruleForm.isRecom = null
        this.ruleForm.typeId = null
      })
    }
  }
}
</script>
<style scoped>
.addBox {
    margin-top: 10px;
    height: 450px;
    width: 400px;
    left: 50%;
}
.sure {
    position: absolute;
    left: 200px
}
</style>>
